package com.jinbo.footmessage.order;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.jinbo.footmessage.BaseActivity;
import com.jinbo.footmessage.MyApplication;
import com.jinbo.footmessage.R;
import com.jinbo.footmessage.httpbean.OrderBean;
import com.jinbo.footmessage.httpbean.WorkerInformationBean;
import com.jinbo.footmessage.httpretrofit.HttpProtocolFactory;
import com.jinbo.footmessage.serverInf.EditOrderInfActivity;
import com.jinbo.footmessage.serverInf.ServerInfActivity;
import com.jinbo.footmessage.utils.LocalPreferencesHelper;
import com.jinbo.footmessage.view.TitleBarView;

import de.hdodenhof.circleimageview.CircleImageView;

public class LookOrderActivity extends BaseActivity implements View.OnClickListener{
    private static String ORDER_INTENT = "order_bean";
    TextView mDateTV, mWeekTV, mBeginTV, mEndTv, mProjectsTv, mTotalPriceTv, mNameTv;
    TextView mContactNameTv, mContactPhoneTv, mContactAddressTv, mContactSexTv;
    CircleImageView head;

    OrderBean bean;
    public static void launch(Activity activity,OrderBean orderBean) {
        Intent intent = new Intent(activity, LookOrderActivity.class);
        Bundle bundle = new Bundle();
        bundle.putSerializable(ORDER_INTENT, orderBean);
        intent.putExtras(bundle);
        activity.startActivity(intent);
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_look_order);
        TitleBarView titleBarView = (TitleBarView) findViewById(R.id.titleBar);
        titleBarView.setCenterTitle("查看订单");
        titleBarView.setLeftBackButtonIsVisibler(true);
        titleBarView.setListener(TitleBarView.TitleBarEnum.ll_leftBackImageLayout, this);;
        mDateTV = (TextView) findViewById(R.id.date);
        mWeekTV = (TextView) findViewById(R.id.day_of_week);
        mBeginTV = (TextView) findViewById(R.id.begin_time);
        mEndTv = (TextView) findViewById(R.id.end_time);
        mProjectsTv = (TextView) findViewById(R.id.projects);
        mTotalPriceTv = (TextView) findViewById(R.id.total_price);
        mNameTv = (TextView) findViewById(R.id.name);
        head = (CircleImageView) findViewById(R.id.head);
        Intent intent = this.getIntent();
        bean = (OrderBean) intent.getSerializableExtra(ORDER_INTENT);
        mDateTV.setText(bean.date);
        mWeekTV.setText(bean.week);
        mBeginTV.setText(bean.begin_time);
        mEndTv.setText(bean.end_time);
        mProjectsTv.setText(bean.content);//getProjectNames(bean.worker.projects));
        mTotalPriceTv.setText(bean.total_price);//getPrice(bean.worker.projects) + "");
        Glide.with(this)
                .load(HttpProtocolFactory.HOST_URL_USER + bean.worker.head)
                .into(head);
        mNameTv.setText(bean.worker.name);

        mContactNameTv = (TextView) findViewById(R.id.contact_name);
        mContactPhoneTv = (TextView) findViewById(R.id.contact_phone);
        mContactAddressTv = (TextView) findViewById(R.id.contact_address);
        mContactSexTv = (TextView) findViewById(R.id.contact_sex);


        mContactNameTv.setText(bean.contact_name);
        mContactPhoneTv.setText(bean.contact_phone);
        mContactAddressTv.setText(bean.contact_address);
        mContactSexTv.setText(bean.contact_sex);
        head.setOnClickListener(this);

    }
    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.left_back_layout:
                finish();
                break;
            case R.id.head:
                ServerInfActivity.launch(this,bean.worker);
                break;
        }
    }
}
